<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'search';
$delete = $base_url;
$delete['action'] = 'del';
$add = $base_url;
$add['action'] = 'add';
$import = $base_url;
$import['action'] = 'import';
$output = $base_url;
$output['action'] = 'output';
$exp = $base_url;
$exp['action'] = 'exp';
$change = $base_url;
$change['action'] = 'userchange';
?>
<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td ><label>卡号：</label>
				<input type="text" name="cardname" value="<?php echo isset($param['cardname'])?$param['cardname']:'';?>"/>
				<input type="hidden" name="_querymethod[cardname]" value="like"></td>
			<td>
				<label>金额：</label>
				<input type="text" size="6" class="number" name="balance" value="<?php echo isset($param['balance'])?$param['balance']:'';?>"/>
			</td><td>
				<label>充值卡状态：</label>
				<select name="vouchered">
				<option value="">所有</option>
				<option value="0" <?php echo isset($param['vouchered'])?$param['vouchered'] == 0?'selected':'':''; ?>>未使用</option>
				<option value="1" <?php echo isset($param['vouchered'])?$param['vouchered'] == 1?'selected':'':''; ?>>已被充值</option>
			</td>
			
			<td>
				<span>被充值帐号：</span>
				<input type="text" name="voucher_acctname" value="<?php echo isset($param['voucher_acctname'])?$param['voucher_acctname']:'';?>"/>
				<input type="hidden" name="_querymethod[voucher_acctname]" value="like">
			</td>
			
			<td>
				<label>所属代理：</label>
				<select name="agent_id">
				<option value="">请选择代理....</option>
				<?php foreach ($agent_list as $k=>$v):?>
				<option value="<?php echo $k;?>" <?php echo isset($param['agent_id'])?$param['agent_id'] == $k?'selected':'':''; ?>><?php echo $v;?></option>
				<?php endforeach;?>
				</select>
			</td>
			
			</tr>
			<tr>
			<td>
				<span>创建日期：</span>
				<input type="text" class="date" name="createtime" value="<?php echo isset($param['createtime'])?$param['createtime']:'';?>"/>
				<input type="hidden" name="_querymethod[createtime]" value="like">
			</td>
			<td>
				<span>充值日期：</span>
				<input type="text" class="date" name="activedate" value="<?php echo isset($param['activedate'])?$param['activedate']:'';?>"/>
				<input type="hidden" name="_querymethod[activedate]" value="like">
			</td>
			<td>
				<span>免费注册ID：</span>
				<input type="text"  name="payid" value="<?php echo isset($param['payid'])?$param['payid']:'';?>"/>
				<input type="hidden" name="_querymethod[payid]" value="like">
			</td>
			<td>
				<label>充值卡类型：</label>
				<select name="cardtype">
				<option value="0" <?php echo isset($param['cardtype'])?$param['cardtype'] == 0?'selected':'':''; ?>>普通卡</option>
				<option value="1" <?php echo isset($param['cardtype'])?$param['cardtype'] == 1?'selected':'':''; ?>>月卡</option>
			</td>
			<td>
				<label>ID起止：</label>
				>=<input type="text" name="id_begin" size="6" value="<?php echo isset($param['id_begin'])?$param['id_begin']:'';?>"/>
				< <input type="text" name="id_end" size="6" value="<?php echo isset($param['id_end'])?$param['id_end']:'';?>"/>
			</td>
			</tr>
			
		</table>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit" value="fuck">检索</button></div></div></li>
				
				<li><a class="button" href="<?php echo url($change,null,null,array('mode'=>'standard'));?>" target="dialog" mask="true" title="查询框" width="500" height="500"><span>查询批量修改</span></a></li>
			</ul>
		</div>
	</div>
	</form>
	<form action="<?php echo url($output)?>" method="post" >
		<ul class="searchContent">
			<select name="idflag">
			<option value="0">默认</option>
			<option value="1">导出ID</option>
			</select>
			<li><input type="submit" value="导出查询结果"></li>
		</ul></form>
</div>

<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			
			<li><a title="确认删除选中的数据?" target="selectedTodo" rel="ids[]" href="<?php echo url($delete)?>" class="delete"><span>批量删除</span></a></li>
			<li class="line">line</li>
			
			<li><a class="edit" href="<?php echo url($import)?>" target="dialog" rel="生成卡密" height="500" ><span>生成卡密</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($exp)?>" target="dialog" rel="导入卡密" height="500" ><span>导入卡密</span></a></li>
			<li class="line">line</li>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="228">
		<thead>
			<tr>
				<th width="5%"><input type="checkbox" group="ids[]" class="checkboxCtrl">ID</th>
				<th width="8%">分销 </th>
				<th width="10%" orderField="cardname" >卡号</th>
				<th width="5%" >密码</th>
				<th width="5%" >金额</th>
				<th width="8%" >回铃限制</th>
				<th width="5%" >有效期 	</th>
				<th width="10%" >(费率组)呼出/回铃</th>
				<th width="5%" >	状态</th>
				<th width="5%" >充值	</th>
				
				<th width="5%" align="center">被充值帐号 </th>
				<th width="5%" align="center">充值卡类型 </th>
				<th width="5%" align="center">免费注册ID</th>
				<th width="8%" align="center">套餐</th>
				<th width="10%" align="center">操作</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach ($item as $k=>$v):?>
			<tr target="id" rel="<?php echo $v->id?>">
				<td><input name="ids[]" value="<?php echo $v->id?>" type="checkbox"><?php echo $v->id;?></td>
			
				<td><?php echo $v->agent->acctname;?></td>
				<td><?php echo $v->cardname;?></td>
				<td><?php echo $v->password;?></td>
				<td><?php echo sprintf('%f',$v->balance);?></td>
				<td><?php echo sprintf('%f',$v->limitbalance);?></td>
				<td><?php echo $v->expireddays;?></td>
				<td><?php echo $v->a_rategroup->rategroupname.'/'.$v->b_rategroup->rategroupname;?></td>
				<td><?php echo $v->enable == 1 ?'激活':'失效';?></td>
				<td><?php echo $v->vouchered == 1 ?'已经充值':'未使用';?></td>
				
				<td><?php echo $v->voucher_acctname;?></td>
				<td><?php echo $v->cardtype==0?'普通卡':'月卡-('.$v->automoney.')';?></td>
				<td><?php echo $v->payid;?></td>
				<td><?php echo $v->packageid ? Acctpackage::get_packname($v->packageid):'';?></td>
				<td><?php if($v->enable == 1 && $v->vouchered == 0):?>
					<a href="<?php echo url("card/pay",array('cardname'=>$v->cardname,'password'=>$v->password))?>" target="dialog">充值</a>
				<?php endif;?>
				
				</td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
<div class="panelBar">
			<div class="pages">
			<span>显示</span>
			<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==20)echo 'selected=selected';?>>20</option>
				<option value="50" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==50)echo 'selected=selected';?>>50</option>
				<option value="100" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==100)echo 'selected=selected';?>>100</option>
				<option value="200" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==200)echo 'selected=selected';?>>200</option>
			</select>
				<span>共 <?php echo $pagination['record_count'];?> 条</span>
			</div>
		
		<div class="pagination" targetType="navTab" totalCount="<?php echo $pagination['record_count'];?>" numPerPage="<?php echo $pagination['page_size'];?>" pageNumShown="10" currentPage="<?php echo $pagination['current'];?>" ></div>

	</div>	
</div><iframe width="0" height="0" id="down" name="down"></iframe>